/**
 * author: zhangwei
 * 角色新增、编辑
 */
var pageType = "add";
var main = {

    init: function() {
        doctorAppointmentId = localStorage.doctorAppointmentId;
        doctorCode = localStorage.doctorCode;
        $("#appointmentId").val(doctorAppointmentId);
        $("#doctorCode").val(doctorCode);
        this.initTable();
    },
    initTable: function() {
        var cyProps = "url:'"+"/org/queryOrgListTree',name:'orgId'";
        $("#orgId").attr("cyProps",cyProps);
        layui.use(['form','laydate'], function() {
            var form = layui.form;

            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#test1' //指定元素
            });

            //监听提交
            form.on('submit(formSubmit)', function(data) {
                var url = "/doctorComment/saveDoctorComment?userComment="+1;
                var json = $("#roleForm").serialize();
                $.ajax({
                    type:"post",
                    data:json,
                    async:false,
                    url:url,
                    success:function(result) {
                        if (result.code == property.successCode) {
                            if(pageType == "edit"){
                                successMsg("修改成功");
                            }else{
                                successMsg("添加成功");
                            }
                            parent.$t.goback("/doctorComment/manage");
                        } else{
                            errorMsg(result.msg);
                        }
                    },
                    error:function(result) {
                        errorMsg("系统异常");
                    }
                });
                return false;
            });

            //监听重置
            $("#cancel").click(function () {
                parent.$(".myRefresh").click();
                layer.close(index);
                return false;
            });

        });
    },
    getDetailData: function() {
        layui.use('form', function() {
            var form = layui.form;
            form.val("myform", {
                "title": "贤心"
                ,"name": "vvvvv"
                ,"city": "1"  // 下拉框初始赋值
                ,"desc": "我爱layui"
            });
        });
    }
}
main.init();



/**
 * 设置表单数据
 * @param data
 */
function setFormData(data) {

    property.setForm($("#roleForm"),data);

}



